<template>
  <div class="page">
    <div class="page-title">
      绿债评估机构
    </div>

    <div class="page-content">
      <div class="page-content-screen">
        <div class="screen">
          <search-input title="关键词" :width="175" v-model="searchTxt"
                        placeholder="请输入企业名称"
                        @enter="handlerInput" @clear="handlerInput"/>
        </div>
        <div class="total">共计 <sapn style="color: rgba(255, 89, 89, 1)">{{ totalNum }}</sapn> 条</div>
      </div>
      <div class="page-content-table">
        <vc-table
          :loading="loading"
          :tableData="tableData"
          :columns="columns"
          :total="totalNum"
          :pageSize="PAGE_SIZE"
          :pageNum="queryData.pageNum"
          :defaultSort="{ field: 'noticeDate', order: 'desc' }"
          :maxHeight="maxHeight"
          @page-change="handleCurrentChange"
          @sort-change="sortChange"
        />
      </div>
    </div>
    <vc-dialog v-model="showBondEvaluateDetail"
               title="绿债评估机构详情" width="1200"
               height="80vh">
      <div class="detail-table">
        <evaluate-detail-table :companyId="BondEvaluateDetails.companyId"
                               :index="BondEvaluateShowIndex"></evaluate-detail-table>
      </div>
    </vc-dialog>
  </div>
</template>
<script lang="ts" setup>
import {getGreenBondEvaluation} from '../apis';
import {useTable} from './useTable';
import {useScreen} from './useScreen';
import {calculateTableMaxHeight} from "@/utils";
import searchInput from '@/components/page-search/index.vue';
import {usePage} from '@/use/usePage';
import TopTab from "@/views/modules/greenBond/components/top-tab.vue";
import evaluateDetailTable from './../components/evaluate-detail-table/index.vue';

const {PAGE_SIZE, screen, queryData} = useScreen();
let maxHeight = $ref(0)
queryData.bondCompanyType = 1
const {data, loading, run} = useRequest(getGreenBondEvaluation, {
  defaultParams: [{...queryData}],
  onSuccess: (data) => {
    tableData.value = data.values;
    totalNum.value = data.total;
    nextTick(() => {
      //计算最大高度
      maxHeight = calculateTableMaxHeight()
    })
  }
});
//页面resize，重新计算高度
window.onresize = function () {
  maxHeight = calculateTableMaxHeight()
}
const {columns, showBondEvaluateDetail, BondEvaluateDetails, BondEvaluateShowIndex} = useTable();
const {
  tableData,
  totalNum,
  searchTxt,
  handlerInput,
  handleCurrentChange,
  sortChange
} = usePage(queryData, run);

</script>
<style lang="scss" scoped>
@import "./index.scss";
</style>
